<template>
	<view>
		<view class="bg-white">
			<view class="solid"></view>
			<view class="K flex align-center">
				<text>打印机编号</text>
				<input type="text" placeholder="请输入打印机编号" v-model="number">
			</view>
			<view class="K flex align-center">
				<text>打印机秘钥</text>
				<input type="text" placeholder="请输入打印机秘钥" v-model="password">
			</view>
		</view>
		<view class="food bg-white">
			<text>提示：使用飞鹅自动接单外卖打印机FP-58W</text>
			<view class="button flex-c" @click="handleBC">保存</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				number:'',
				password:''
			};
		},
		onLoad(e) {
			this.$api.merchant({},true).then(res=>{
				this.number = res.data.printer_sn
				this.password = res.data.printer_key
			})
		},
		methods:{
			handleBC(){
				if(this.number == ''){
					this.$utils.tips('请输入打印机编号')
					return
				}
				if(this.password == ''){
					this.$utils.tips('请输入打印机秘钥')
					return
				}
				this.$api.change_shop_printer({
					printer_sn:this.number,
					printer_key:this.password
				}).then(res=>{
					console.log(res);
					if(res.data.data.ok.langth == 1){
						uni.navigateBack()
					}else{
						this.$utils.tips(''+res.data.data.no)
					}
				})
			}
		}
	}
</script>

<style lang="scss">
.K{
	padding: 30rpx 20rpx;
	border-bottom: 1rpx solid #f8f8f8;
	input{
		margin-left: 30rpx;
		flex: 1;
	}
}
.K:nth-last-of-type(1){
	border: none;
}
.food{
	height: calc(100vh - 230rpx);
	margin-top: 20rpx;
	padding: 20rpx ;
	position: relative;
}
.button{
	width: 710rpx;
	height: 80rpx;
	border-radius:40rpx;
	background-color: rgb(253, 136, 36);
	color: #fff;
	font-size: 32rpx;
	position: absolute;
	bottom: 50rpx;
}
</style>
